package com.cos.config;

import com.cos.mq.MQ;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MQConfig {

    @Bean
    public TopicExchange getTopicExchange(){
        return new TopicExchange(MQ.GOODS_EXCHANGE,true,false);
    }

    @Bean
    public Queue getQueue(){
        return new Queue(MQ.GOODS_ES_QUEUE,true);
    }

    @Bean
    public Binding getBinding(){
        return  BindingBuilder.bind(getQueue()).to(getTopicExchange()).with("goods.*");
    }

}
